package com.yupi.project.controller;
import com.yupi.project.common.BaseResponse;
import com.yupi.project.common.ResultUtils;
import com.yupi.project.model.dto.famer.GoodsDto;
import com.yupi.project.service.FarmerService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RequestMapping("/farmer")
@RestController
public class FarmerController {
    @Resource
    private FarmerService farmerService;

    @RequestMapping("/selectAll")
    public BaseResponse selectAll() {
        return ResultUtils.success(farmerService.list());
    }
    /**
     * 添加商品到农民表中去
     * @return
     */
    @PostMapping("/addFoods")
    public BaseResponse addFoods(GoodsDto goods,
                                 @RequestParam("image") MultipartFile image) {
        return farmerService.addFoods(goods, image);
    }
}
